﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DosciWordPlugin.Common;

namespace DosciWordPlugin.Controls
{
    public partial class InsertOther : Form
    {
        public event Func<string,bool> InsertOtherTextEvent;

        public InsertOther()
        {
            InitializeComponent();
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            try
            {
                string content = txtContent.Text.Trim();
                if (string.IsNullOrEmpty(content))
                {
                    WinApp.MsgBoxInfo("请输入内容");
                    return;
                }

                if (InsertOtherTextEvent != null)
                {
                    bool insertSuc = InsertOtherTextEvent(content);
                    if (insertSuc)
                    {
                        WinApp.MsgBoxInfo("插入成功！");
                        DialogResult = System.Windows.Forms.DialogResult.OK;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                WinApp.MsgBoxError(ex.Message);
            }
        }
    }
}
